home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2004 April / SGI IRIX 6.5 Applications 2004 April.iso / dist / mozilla.idb / var / netscape / mozilla / mozilla-xremote-client.sh.z / mozilla-xremote-client.sh
Linux/UNIX/POSIX Shell Script  |  2004-01-06  |  4KB  |  162 lines

  1. #!/bin/sh
  2. #Tag 0x10646
  3. #
  4. # The contents of this file are subject to the Netscape Public License
  5. # Version 1.0 (the "NPL"); you may not use this file except in
  6. # compliance with the NPL.  You may obtain a copy of the NPL at
  7. # http://www.mozilla.org/NPL/
  8. #
  9. # Software distributed under the NPL is distributed on an "AS IS" basis,
  10. # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  11. # for the specific language governing rights and limitations under the
  12. # NPL.
  13. #
  14. # The Initial Developer of this code under the NPL is Netscape
  15. # Communications Corporation.  Portions created by Netscape are
  16. # Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  17. # Reserved.
  18. #
  19.  
  20. ## $Id: mozilla-xremote-client.sh,v 1.4 2003/07/23 02:08:39 nickb Exp $
  21. ## 
  22. ## Usage:
  23. ##
  24. ## $ mozilla [args]
  25. ##
  26. ## This script is meant to run the mozilla-xremote-client binary 
  27. ##
  28. ## The script will setup all the environment voodoo needed to make
  29. ## the mozilla-bin binary to work.
  30. ##
  31.  
  32. #uncomment for debugging
  33. #set -x
  34.  
  35. moz_libdir=/var/netscape/mozilla
  36. MRE_HOME=/usr/local/lib/mre/mre-1.0.1
  37. # Changed to "new-window" if you prefer a new window rather than tab
  38. OPTION="new-tab"
  39.  
  40. # honor MOZILLA_FIVE_HOME if it's there
  41. if [ -n "$MOZILLA_FIVE_HOME" ] ; then
  42.   dist_bin="$MOZILLA_FIVE_HOME"
  43. else
  44.   # Use run-mozilla.sh in the current dir if it exists
  45.   # If not, then start resolving symlinks until we find run-mozilla.sh
  46.   found=0
  47.   progname=$0
  48.   curdir=`dirname $progname`
  49.   run_moz="$curdir/run-mozilla.sh"
  50.   if test -x $run_moz; then
  51.     dist_bin=$curdir
  52.     found=1
  53.   else
  54.     here=`/bin/pwd`
  55.     while [ -h "$progname" ]; do
  56.       bn=`basename "$progname"`
  57.       cd `dirname "$progname"`
  58.       progname=`/bin/ls -l "$bn" |sed -e 's/^.* -> //' `
  59.       if [ ! -x "$progname" ]; then
  60.         break
  61.       fi
  62.       curdir=`dirname $progname`
  63.       run_moz="$curdir/run-mozilla.sh"
  64.       if [ -x $run_moz ]; then
  65.         cd $curdir
  66.         dist_bin=`pwd`
  67.         found=1
  68.         break
  69.       fi
  70.     done
  71.     cd $here
  72.   fi
  73.   if [ $found = 0 ]; then
  74.     # Check default compile-time libdir
  75.     if [ -x "$moz_libdir/run-mozilla.sh" ]; then
  76.       dist_bin=$moz_libdir
  77.     else 
  78.       echo "Cannot find mozilla runtime directory. Exiting."
  79.       exit 1
  80.     fi
  81.   fi
  82. fi
  83.  
  84. script_args=""
  85. moreargs=""
  86. debugging=0
  87. XREMOTE_BIN="mozilla-xremote-client"
  88. MOZILLA_BIN="mozilla-bin"
  89.  
  90. if [ "$OSTYPE" = "beos" ]; then
  91.   mimeset -F $MOZILLA_BIN
  92. fi
  93.  
  94. while [ $# -gt 0 ]
  95. do
  96.   case "$1" in
  97.     -g | --debug)
  98.       script_args="$script_args -g"
  99.       debugging=1
  100.       shift
  101.       ;;
  102.     -d | --debugger)
  103.       script_args="$script_args -d $2"
  104.       shift 2
  105.       ;;
  106.     -mailto)
  107.      startup_args="-compose to="
  108.         remote_args="mailto("
  109.         if [ $2 ]; then
  110.                 remote_args="$remote_args $2"
  111.         startup_args="$startup_args$2"
  112.                 shift 1
  113.                 while [ $2 ] ; do
  114.                         remote_args="$remote_args, $2"
  115.             startup_args="$startup_args $2"
  116.                         shift 1
  117.                 done
  118.         fi
  119.         remote_args="$remote_args )"
  120.     startup_args="$startup_args"
  121.     shift 1
  122.       ;;
  123.     -mail)
  124.         remote_args="xfeDoCommand(openInbox)"
  125.     startup_args="-mail"
  126.         shift 1
  127.       ;;
  128.     -editor)
  129.     remote_args="-editor"
  130.     startup_args="-editor"
  131.     shift 1
  132.     if [ $1 ]; then
  133.         startup_args="-edit $1"
  134.         shift 1
  135.     fi
  136.      ;;
  137.     *)
  138.       moreargs="$moreargs \"$1\""
  139.       shift 1
  140.       ;;
  141.   esac
  142. done
  143.  
  144. export MRE_HOME
  145. eval "set -- $moreargs"
  146. if [ -z "$remote_args" ]; then
  147.     remote_args="openURL($1, $OPTION)"
  148.     startup_args="$1"
  149. fi
  150.  
  151. # no way to invoke the editor by "remote" :-(
  152. if [ "$remote_args" = "-editor" ]; then
  153.     ${dist_bin}/run-mozilla.sh $script_args $dist_bin/$MOZILLA_BIN -splash dummy_arg $startup_args &
  154. else
  155.     $dist_bin/run-mozilla.sh $script_args $dist_bin/$XREMOTE_BIN "$remote_args"
  156.     if [ $? -eq 2 ]; then
  157. # note: the dummy_arg is necessary as the arg parsing code swallows the arg after a -arg
  158.         ${dist_bin}/run-mozilla.sh $script_args $dist_bin/$MOZILLA_BIN -splash dummy_arg $startup_args &
  159.     fi
  160. fi
  161.  
  162.